 <?php 
session_start(); 

?>  
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>

<header  class="headBar" style="
    z-index: 100;">
    <div  class="settingBar">
        <div  class="container-fluid">
            <div  class="row">
                <div  class="colorCol">
                    <ul  class="ng-tns-c8-0"></ul>
                </div>
            </div>
        </div>
    </div>
   
        <div  class="container-fluid">
        <div  class="row align-items-center">
            <div  class="col-4 col-sm-3 col-md-2 col-lg-1 position-relative pl-2 pl-lg-0">
    <a  class="headLogo" href="/">
        <img  class="ng-tns-c8-0" src="https://veritral.com/logos/VeritralTextType1.png" alt="RedBets Logo">
    </a>
</div>

            <div  class="col-8 col-sm-9 col-md-10 col-lg-11 d-md-flex justify-content-between align-items-center">
                <div  class="d-none d-md-flex headerSocialIcon align-items-end">
                    <a class="socialIconText" href="javascript:void(0);" onclick="openLiveChat()">  <i class="fa-solid fa-headset mr-1"></i>  <span>Canlı Destek</span></a><!-- Comm100 Live Chat Code --><div id="comm100-button-20465543-6eac-493a-8945-1647201adf07"></div><script type="text/javascript">  var Comm100API=Comm100API||{};  (function(t){    function e(e){      var a=document.createElement("script"),          c=document.getElementsByTagName("script")[0];      a.type="text/javascript",      a.async=!0,      a.src=e+t.site_id,      c.parentNode.insertBefore(a,c);    }    t.chat_buttons=t.chat_buttons||[],    t.chat_buttons.push({      code_plan:"20465543-6eac-493a-8945-1647201adf07",      div_id:"comm100-button-20465543-6eac-493a-8945-1647201adf07"    }),    t.site_id=90006604,    t.main_code_plan="20465543-6eac-493a-8945-1647201adf07",    e("https://vue.comm100.com/livechat.ashx?siteId="),    setTimeout(function(){      t.loaded||e("https://standby.comm100vue.com/livechat.ashx?siteId=");    }, 5e3);  })(Comm100API||{});  function openLiveChat() {    Comm100API.showChatWindow();  }</script><!-- End Comm100 Live Chat Code -->
                    
                    
                    
                    <a  class="socialIconText ng-tns-c8-0 ng-star-inserted" href="https://t.me/Veritral1" target="_blank"><i  class="fa-brands fa-telegram mr-1"></i><span  class="ng-tns-c8-0">TELEGRAM</span></a></div>
   
                
     <?php
// Şu anki domaini alalım
$currentDomain = $_SERVER['HTTP_HOST'];  

// Domaini '.' ile ayıralım ve son kısmı alalım (domainin sonundaki sayıyı)
$currentDomainParts = explode('.', $currentDomain);

// Son kısımdaki sayıyı alalım (önce domain kısmını al, sayıyı ekle)
$currentDomainWithoutTld = $currentDomainParts[0]; // gatesofbet392 kısmı
$currentNumber = (int) filter_var($currentDomainWithoutTld, FILTER_SANITIZE_NUMBER_INT);

// Sonraki domaini hesapla
$nextNumber = $currentNumber + 1; // Bir sonraki numara
$nextDomain = "Veritral" . $nextNumber . ".com"; // Örneğin gatesofbet393.com
?>

<script>
    // Sayfa yüklendiğinde disclaimer'ı gösterip gizle
    window.onload = function() {
        if (!localStorage.getItem('disclaimerClosed')) {  // Eğer disclaimer kapatılmadıysa
            document.querySelector('.disclamer').style.display = 'block'; // Göster
        } else {
            document.querySelector('.disclamer').style.display = 'none'; // Gizle
        }
    }

    function closeDisclaimer() {
        var disclaimerElement = document.querySelector('.disclamer');
        if (disclaimerElement) {
            disclaimerElement.style.display = 'none'; // Div'i gizle
            localStorage.setItem('disclaimerClosed', 'true'); // Kapatıldığını kaydet
        }
    }
</script>

<div class="disclamer" style="display: none;"> <!-- Başlangıçta gizli -->
    <strong>
        Güncel Domain Adresimiz <?php echo htmlspecialchars($currentDomain); ?>.
        Bir sonraki adresimiz <?php echo htmlspecialchars($nextDomain); ?>&nbsp;olacaktır.
    </strong>
    <i class="fas fa-times close-button" onclick="closeDisclaimer()"></i>
</div>
           
<?php if (isset($_SESSION['error_message'])): ?>
        <script>
            document.addEventListener('DOMContentLoaded', function() {
                Swal.fire({
                    icon: 'error',
                    title: 'Hesabınıza giriş  yapınız!',
                    text: '<?php echo htmlspecialchars($_SESSION['error_message']); ?>',
                    confirmButtonText: 'Tamam',
                    customClass: {
                        popup: 'swal-popup-custom' // Mobil için özel CSS
                    }
                }).then(() => {
                    // Kullanıcı "Tamam" butonuna bastığında yönlendirme yapılabilir
                    window.location.href = '/';
                });
            });
        </script>
        <?php unset($_SESSION['error_message']); // Mesajı temizle ?>
    <?php endif; ?>


                
                
                <div  class="headerItem">
                
                    
                    <div  class="loginCol ng-tns-c8-0 ng-star-inserted">
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            if (<?php echo json_encode(isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true); ?>) {
                // Kullanıcı giriş yapmışsa API'den ana bakiyeyi çek
                fetch('../api/balanceapi')
                    .then(response => response.json())
                    .then(data => {
                        if (data.status === 'success') {
                            // Bakiye başarılı bir şekilde çekildiyse span'a yaz
                            document.querySelector('.balText').textContent = data.ana_bakiye;
                            // Diğer yerlerde de bakiyeyi güncelle
                            const playerBalanceLink = document.querySelector('.playerCol .mobile-section .pl-link b.float-right');
                            if (playerBalanceLink) {
                                playerBalanceLink.textContent = data.ana_bakiye;
                            }
                        } else {
                            console.error(data.message); // Hata mesajını konsola yazdır
                        }
                    })
                    .catch(error => console.error('Hata:', error));
            }
        });
    </script>





<a href="/cert.gcb.cw/" 
   target="_blank" class="header-icon">
    <img src="https://cmsbetconstruct.com/storage/medias/dengebet/media_1873833_7ba968924a3eba7108d5501a7a09772c.jpeg" 
         alt="Certificate" class="header-image">
</a>




<style>

.header-image {
    width: auto; /* Varsayılan olarak genişlik ayarlanır */
    height: auto; /* Oranı korur */
    max-width: 150px; /* Varsayılan maksimum genişlik */
    max-height: 50px; /* Varsayılan maksimum yükseklik */
    object-fit: cover; /* Görselin çerçeveye uygun bir şekilde kırpılması */
}

/* Ekran genişliği 768px'den küçük olduğunda (mobil cihazlar) */
@media screen and (max-width: 768px) {
    .header-image {
        max-width: 120px; /* Daha küçük genişlik */
        max-height: 40px; /* Daha küçük yükseklik */
    }
}

/* Ekran genişliği 480px'den küçük olduğunda (küçük telefonlar) */
@media screen and (max-width: 480px) {
    .header-image {
        max-width: 100px; /* Daha da küçük genişlik */
        max-height: 30px; /* Daha da küçük yükseklik */
    }
}


</style>


<?php if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true): ?>
    <!-- Kullanıcı giriş yapmışsa -->
<button class="btn btn-primary depositBtn" type="button" onclick="redirectToDeposit()">Para Yatır</button>

<script>
    function redirectToDeposit() {
        window.location.href = "/profile/deposit-withdraw";
    }
</script>

<span class="balText" style="display: inline-block; padding: 0.3rem 0.4rem; margin: 0 0 0 0.3rem; font-size: 10px; height: 30px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; box-sizing: border-box;">0.00₺</span>

<div class="playerCol">
    <button class="userBtn" id="toggleButton">
        <i class="fa-solid fa-circle-user"></i>
    </button>

<div class="playerNav hidesection" id="playerNav">
    <div class="mobile-section">
        <div class="pl-link">ANA BAKİYE <b class="float-right">0.00₺</b></div>
        <div class="pl-link">Bonus Bakiyesi <b class="float-right">0₺</b></div>
    </div>
    <a class="pl-link" href="/profile/account-details"><i class="fa-solid fa-user"></i> Profilim</a>
    <a class="pl-link" href="/profile/account-statement"><i class="fa-solid fa-money-bill-1"></i> İşlem Geçmişi</a>
    <a class="pl-link" href="/profile/bet-history"><i class="fa-solid fa-money-bill-transfer"></i> Casino Geçmişi</a>
        <a class="pl-link" href="/profile/bahis-gecmis"><i class="fa-solid fa-money-bill-transfer"></i> Bahis Geçmişi</a>
    <a class="pl-link" href="/promotions"><i class="fa-solid fa-gift"></i> Promosyonlar</a>
    <a class="pl-link" id="bonusRequestLink" style="cursor: pointer;">
        <i class="fa-solid fa-gift"></i> Bonus Talep
    </a>
      <a class="pl-link" href="/profile/deposit-withdraw"><i class="fa-solid fa-money-bill-1"></i> Para Yatırma/Para Çekme</a>
    
    <a class="pl-link"  href="/profile/kyc"><i class="fa-solid fa-address-card"></i> Kyc</a>
<a class="pl-link" style="cursor: pointer" onclick="bonusKoduKullan()">
    <i class="fa-solid fa-gift"></i> Bonus Kodu Kullan
</a>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
function bonusKoduKullan() {
    Swal.fire({
        title: 'Bonus Kodunuzu Girin',
        input: 'text',
        inputLabel: 'Bonus Kodu',
        inputPlaceholder: 'Kodu buraya girin',
        showCancelButton: true,
        confirmButtonText: 'Kullan',
        cancelButtonText: 'İptal'
    }).then((result) => {
        if (result.isConfirmed) {
            const kod = result.value;
            
            // API çağrısı için kodu gönder
            fetch('../inc/bonus_kodu_kullan.php', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({ kod: kod })
            })
            .then(response => response.json())
            .then(data => {
                Swal.fire(data.mesaj); // API'den gelen mesajı göster
            })
            .catch(error => {
                Swal.fire('Hata oluştu, lütfen tekrar deneyin.');
                console.error('Error:', error);
            });
        }
    });
}
</script>

    <a class="pl-link" href="logout"><i class="fa-solid fa-right-from-bracket"></i> Çıkış Yap</a>
    <!-- Diğer linkler... -->
</div>

<!-- Bonus Talep Modalı -->
<div class="modal fade bonus-requestIframeStyle" id="custome-promotion" role="dialog" tabindex="-1" style="display: none;">
    <div class="modal-dialog" role="document">
        <div class="modal-content modalfreamheight">
            <div class="modal-header">
                <h5 class="modal-title">Bonus Talep</h5>
                <button class="close" data-dismiss="modal" title="Close" type="button">
                    <i class="fa-solid fa-xmark"></i>
                </button>
            </div>
            <div class="modal-body overflow-hidden" id="scrolltop">
                <iframe class="ifreamview" width="100%" src="/bonustalep/"></iframe>
            </div>
        </div>
        </div>

<style>
.hidesection {
    display: none; /* Başlangıçta gizli */
}
.modal.show {
    display: block !important; /* Modal görünürlüğünü zorla */
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}
.modal {
    display: none; /* Varsayılan olarak gizli */
    opacity: 0;
}
</style>

<script>
document.addEventListener('DOMContentLoaded', function() {
    const toggleButton = document.getElementById('toggleButton');
    const playerNav = document.getElementById('playerNav');
    const bonusRequestLink = document.getElementById('bonusRequestLink');
    const modal = document.getElementById('custome-promotion');
    const closeButton = modal.querySelector('.close');

    // Toggle butonuna tıklandığında menüyü aç/kapa
    toggleButton.addEventListener('click', function(event) {
        event.stopPropagation();
        playerNav.classList.toggle('hidesection');
    });

    // Sayfanın boş alanına tıklandığında menüyü kapat
    document.addEventListener('click', function(event) {
        // Eğer modal açıksa ve modal dışına tıklanırsa menüyü kapat
        if (!modal.contains(event.target) && !playerNav.contains(event.target) && event.target !== toggleButton) {
            playerNav.classList.add('hidesection');
        }
    });

    // Bonus Talep linkine tıklandığında modalı aç
    bonusRequestLink.addEventListener('click', function(event) {
        event.preventDefault();
        modal.style.display = 'block';
        modal.classList.add('show');
        modal.setAttribute('aria-hidden', 'false');
        // Menüyü açık bırak
    });

    // Modalın kapatma butonuna tıklandığında modalı kapat
    closeButton.addEventListener('click', function() {
        modal.style.display = 'none';
        modal.classList.remove('show');
        modal.setAttribute('aria-hidden', 'true');
    });

    // Modalın dışında bir yere tıklanırsa modalı kapat
    window.addEventListener('click', function(event) {
        if (event.target === modal) {
            modal.style.display = 'none';
            modal.classList.remove('show');
            modal.setAttribute('aria-hidden', 'true');
        }
    });
});
</script>


        </div>
    </div>
<?php else: ?>
    <!-- Kullanıcı giriş yapmamışsa -->
    <button class="btn btn-outline-light loginBtn" type="button" id="Giris"> Giriş</button>
    <button id="openModal" class="btn btn-primary" type="button">Kayıt</button>
<?php endif; ?>


                    <div  class="langSelect dropdown flasee"><a  class="nav-link dropdown-toggle" aria-expanded="false" aria-haspopup="true" data-toggle="dropdown" id="dropdown09"><span  class="flag-icon flag-icon-tr"></span></a>
                        <div  class="dropdown-menu" aria-labelledby="dropdown09">
                            

                            <a  class="dropdown-item ng-tns-c8-0 ng-star-inserted">
                            
                            <span  class="flag-icon flag-icon-tr"></span> Türkçe</a></div>
                            
                            
                    </div><span class="badge currentTime" id="turkeyTime">00:00:00</span>

<script>
    function updateTurkeyTime() {
        const turkeyTime = new Date().toLocaleTimeString("tr-TR", {
            timeZone: "Europe/Istanbul",
            hour12: false
        });
        document.getElementById("turkeyTime").textContent = turkeyTime;
    }

    // Türkiye saatini her saniye günceller
    setInterval(updateTurkeyTime, 1000);
</script>
</span>
                </div>
            </div>
        </div>
    </div>
    <nav  class="mainMenu">
        <ul  class="ng-tns-c8-0">
<li  class="ng-tns-c8-0 ng-star-inserted">
    <a  class="ng-tns-c8-0" href="/sports">
        <i  class="fa-solid fa-volleyball"></i> Spor
    </a>
</li>
<li  class="ng-tns-c8-0 ng-star-inserted">
    <a  class="ng-tns-c8-0" href="/livecasino">
        <i  class="fa-solid fa-dice"></i> Canlı Casino
    </a>
</li>
<li  class="ng-tns-c8-0 ng-star-inserted">
    <a  class="ng-tns-c8-0" href="/slot">
        <i  class="fa-solid fa-diamond"></i> Casino
    </a>
</li>



<li  class="mr-4">
    <sup  class="badge badge-pill badge-success">Yeni</sup>
    <a  class="ng-tns-c8-0" href="javascript:void(0);" onclick="openGame(15000)">
        <i  class="fa fa-plane aviIcon" aria-hidden="true"></i> Aviator
    </a>
</li>

<script>
function openGame(gameId) {
    window.open(`/veritral/game.php?gameid=${gameId}`, '_blank'); // Yeni sekmede aç
}
</script>
<li  class="mr-4">
    <sup  class="badge badge-pill badge-success">Yeni</sup>
    <a  class="ng-tns-c8-0" href="javascript:void(0);" onclick="openGame(23946)">
        <i  class="fa fa-rocket" aria-hidden="true"></i> High Flyer
    </a>
</li>

<script>
function openGame(gameId) {
    window.open(`/veritral/game.php?gameid=${gameId}`, '_blank'); // Yeni sekmede aç
}
</script>
            <li  class="ng-tns-c8-0 ng-star-inserted">
    <a  class="ng-tns-c8-0" href="javascript:void(0);" onclick="openGame(23438)">
        <img  class="menuIconImg" src="https://s3.ap-south-1.amazonaws.com/assets.iceexchange.com/prod/v2-dashboard-pi/header-icon/20230822/308490.svg"> Spaceman
    </a>
</li>

<script>
function openGame(gameId) {
    window.open(`/veritral/game.php?gameid=${gameId}`, '_blank'); // Yeni sekmede aç
}
</script>

<li  class="ng-tns-c8-0 ng-star-inserted">
    <a  class="ng-tns-c8-0" href="/promotions">
        <i  class="fa fa-gift" aria-hidden="true"></i> Promosyonlar
    </a>
</li>
        </ul>
    </nav>
</header>

<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>
<!-- Include jQuery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

<!-- Include Bootstrap JS -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

</head>



<!-- JavaScript -->
<script>
// Giriş butonuna tıklandığında modal açılır
document.getElementById('Giris').addEventListener('click', function() {
    $('#login2').modal('show');  // Modalı göster
});

// Modal kapandığında modalın tamamen sıfırlanması için event listener ekleyelim
$('#login2').on('hidden.bs.modal', function () {
    $(this).find('form').trigger('reset'); // Formu sıfırlar
    $(this).removeData('bs.modal');        // Modal üzerindeki veriyi temizler
});

// Kapama butonuna tıklanınca modal kapanır
document.querySelector('.close').addEventListener('click', function() {
    $('#login2').modal('hide');  // Modalı gizle
});

// Modal açıkken giriş butonuna tekrar tıklanırsa modal açılmaya devam eder
$('#login2').on('show.bs.modal', function () {
    $('#login2').modal('show');  // Modalı tekrar göster
});

</script>

<div class="modal fade" id="login2" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog loginModal modal-dialog-centered">
        <div class="modal-content">
            <div _ngcontent-cnq-c30="" class="row m-0">
                <div _ngcontent-cnq-c30="" class="col-12 modal-header"><img _ngcontent-cnq-c30="" class="lo-logo" src="https://veritral.com/logos/VeritralTextType1.png">
                    <div _ngcontent-cnq-c30="" class="tabsRow">
                        <ul _ngcontent-cnq-c30="" class="nav">

                        </ul>
                    </div>                    <button class="close" aria-label="Close" type="button"><span aria-hidden="true">×</span></button>


                </div>
                <div _ngcontent-cnq-c30="" class="col-6 loginBG ng-star-inserted"><img _ngcontent-cnq-c30="" src="assets/images/loginBG.webp"></div>
                <div _ngcontent-cnq-c30="" class="col-12 col-md-6">
                    <div _ngcontent-cnq-c30="" class="modal-body">
                        <div _ngcontent-cnq-c30="" class="tab-content">
                            <div _ngcontent-cnq-c30="" class="tab-pane fade active show" id="loginForm">
                                <div _ngcontent-cnq-c30="" class="secTitle flex-wrap"><span _ngcontent-cnq-c30="" class="smText">Zaten bir hesabınız var mı?</span>
                                    <h5 _ngcontent-cnq-c30="">Giriş yapın, sizi bekliyoruz</h5>
                                </div>
<script>// Kapama butonuna tıklanınca modal kapanır
document.querySelector('.close').addEventListener('click', function() {
    $('#login2').modal('hide');  // Modalı gizle
});
</script>

<?php
session_start(); // Oturumu başlat


// Veritabanı bağlantı bilgilerini sabitler olarak tanımla
define('DB_HOST', 'localhost'); // Sunucu adı
define('DB_NAME', 'u970746249_Demo3veritral'); // Veritabanı adı
define('DB_USER', 'u970746249_Demo3veritral'); // Kullanıcı adı
define('DB_PASS', 'u970746249_Demo3veritral'); // Şifre

// PDO ile veritabanı bağlantısını kur
try {
    $conn = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=utf8", DB_USER, DB_PASS);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Hata raporlama
} catch (PDOException $e) {
    die("Bağlantı hatası: " . $e->getMessage());
}

// Hata mesajlarını başlat
$username_error = $password_error = "";

// Form gönderildiğinde işlemi başlat
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $username_input = trim($_POST['username']); // Kullanıcı adını temizle
    $password_input = $_POST['password']; // Şifre

    // SQL sorgusunu hazırla
    $sql = "SELECT * FROM kullanicilar WHERE username = :username"; // Parametreli sorgu
    $stmt = $conn->prepare($sql);
    $stmt->bindParam(':username', $username_input); // Parametreyi bağla

    if ($stmt->execute()) {
        $result = $stmt->fetch(PDO::FETCH_ASSOC); // Sonucu al

        if ($result) {
            // Şifre doğrulama
            if (password_verify($password_input, $result['password'])) {
                // Başarılı giriş, oturum başlat
                $_SESSION['loggedin'] = true;
                $_SESSION['username'] = $username_input;

                // JavaScript ile yönlendirme
                echo "<script>window.location.href = '/';</script>";
                exit;
            } else {
                // Şifre hatası mesajı
                $password_error = "Yanlış şifre!";
            }
        } else {
            // Kullanıcı adı hatası mesajı
            $username_error = "Kullanıcı bulunamadı!";
        }
    } else {
        // Hata mesajı: Sorgu çalışmadı
        echo "Hata: Sorgu çalıştırılamadı.";
    }
}
?>

<!-- Login Form -->
<form method="POST" action="" novalidate>
    <div class="form-group">
        <input name="username" class="form-control" type="text" placeholder="Kullanıcı Adı" required>
        <?php if (!empty($username_error)) { ?>
            <div class="text-danger"><?php echo htmlspecialchars($username_error); ?></div>
        <?php } ?>
    </div>
    <div class="form-group">
        <input name="password" class="form-control" type="password" placeholder="Şifre" required>
        <?php if (!empty($password_error)) { ?>
            <div class="text-danger"><?php echo htmlspecialchars($password_error); ?></div>
        <?php } ?>
    </div>
    <div class="row justify-content-center mb-5">
        <div class="col-12">
            <button class="btn btn-primary" type="submit" name="login">Giriş</button>
        </div>
    </div>
</form>



                            </div>

                            </div>
                        </div>
                    </div>
                    <div _ngcontent-cnq-c30="" class="modal-footer ng-star-inserted"></div>
                </div>
            </div>
        </div>
    </div>
</div>












<style>
.hidden {
    display: none !important;
}
</style>

<script>
document.addEventListener('DOMContentLoaded', function() {
    var openModalButton = document.querySelector('#openModal'); // Modal açma butonu
    var loginModal = document.querySelector('#loginModal'); // İlk modal
    var loginModalSecond = document.querySelector('#login'); // İkinci modal
    var closeButtons = document.querySelectorAll('.close'); // Kapatma butonları
    var nextButton = document.getElementById("nextButton"); // Sonraki buton
    var backButton = document.getElementById("backButton"); // Geri buton

    // Modal açma fonksiyonu
    function openModal(modal) {
        modal.classList.remove('hidden');
        modal.classList.add('show');
        modal.style.display = 'block';
    }

    // Modal kapama fonksiyonu
    function closeModal(modal) {
        modal.classList.remove('show');
        modal.style.display = 'none';
        modal.classList.add('hidden');
    }

    // Modal açma butonuna tıklama olay dinleyicisi
    if (openModalButton) {
        openModalButton.addEventListener('click', function() {
            openModal(loginModal); // İlk modalı aç
        });
    }

    // Kapatma butonları için olay dinleyicileri
    closeButtons.forEach(function(button) {
        button.addEventListener('click', function() {
            closeModal(loginModal); // Modalı kapat
            closeModal(loginModalSecond); // İkinci modalı kapat
        });
    });

    // "Sonraki" butonuna tıklama olay dinleyicisi
    if (nextButton) {
        nextButton.addEventListener('click', function() {
            closeModal(loginModal); // İlk modalı kapat
            openModal(loginModalSecond); // İkinci modalı aç
        });
    }

    // "Geri" butonuna tıklama olay dinleyicisi
    if (backButton) {
        backButton.addEventListener('click', function() {
            closeModal(loginModalSecond); // İkinci modalı kapat
            openModal(loginModal); // İlk modalı aç
        });
    }
});
</script>

<div aria-labelledby="exampleModalLabel" class="modal fade hidden" data-backdrop="static" data-focus="false" data-keyboard="false" tabindex="-1" id="loginModal" style="display: none; padding-right: 5px;">
    <div class="modal-dialog loginModal modal-dialog-centered" id="modal-size">
        <div class="modal-content">
            <div class="row m-0">
                <div class="col-12 modal-header">
                    <img class="lo-logo" src="https://veritral.com/logos/VeritralTextType1.png">
                    <button class="close" aria-label="Close" type="button"><span aria-hidden="true">×</span></button>
                </div>
                <div class="col-6 loginBG"><img src="assets/images/loginBG.webp"></div>
                <div class="col-12 col-md-6">
                    <div class="modal-body">
                        <div class="tab-content">
                            <div class="tab-pane fade show active" id="singupForm">
                                <div class="secTitle flex-wrap">
                                    <span class="smText">Yeni üye mi?</span>
                                    <h5>Şimdi kaydolun, çok kolay!</h5>
                                </div>
                                <form novalidate>
                                    <div class="form-group">
                                        <input class="form-control" type="text" placeholder="Ad" id="firstName">
                                    </div>
                                    <div class="form-group">
                                        <input class="form-control" type="text" placeholder="Soyad" id="surname">
                                    </div>
                                    <div class="form-group">
                                        <input class="form-control" type="text" placeholder="Kullanıcı Adı" id="username">
                                    </div>
                                    <div class="form-group">
                                        <input class="form-control" type="email" placeholder="E-Posta" id="email">
                                    </div>
                                    <div class="row justify-content-center mb-5">
                                        <div class="col-12">
                                            <button class="btn btn-primary" type="button" id="nextButton">Sonraki</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer"></div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- İkinci Modal -->
<div aria-labelledby="exampleModalLabel" class="modal fade hidden" data-backdrop="static" data-focus="false" data-keyboard="false" tabindex="-1" id="login" style="padding-right: 5px; display: block;">
    <div class="modal-dialog loginModal modal-dialog-centered smallModal" id="modal-size">
        <div class="modal-content">
            <div class="row m-0">
                <div class="col-12 modal-header">
                    <img class="lo-logo" src="https://veritral.com/logos/VeritralTextType1.png">
                    <button class="close" aria-label="Close" type="button"><span aria-hidden="true">×</span></button>
                </div>
                <div class="col-12 col-md-6">
                    <div class="modal-body">
                        <div class="tab-content">
                            <div class="tab-pane fade show active" id="singupForm">
                                <div class="secTitle flex-wrap">
                                    <span class="smText">Yeni üye mi?</span>
                                    <h5>Şimdi kaydolun, çok kolay!</h5>
                                </div>
                                <form novalidate>
                                    <div class="form-group">
                                        <input class="form-control" type="text" placeholder="Tc Kimlik Numaranız" id="tcKimlikNo">
                                    </div>
                                    <div class="form-group customselectArrow">
                                        <select class="form-control countrycode" id="gender">
                                            <option value="Erkek">Erkek</option>
                                            <option value="Kadın">Kadın</option>
                                        </select>
                                    </div>
                                    
                                    
<div class="form-group">
    <label for="dateRangeDob">Doğum Tarihi</label>
    <input class="form-control" id="dateRangeDob" name="dob" type="date" required>
    <small>Format: yyyy-aa-gg</small>
</div>


                                        
                                        
                                        <div class="form-group">
                                            <input class="form-control" type="text" placeholder="Telefon Numarası" id="phone">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <input class="form-control" type="password" placeholder="Şifre" id="password">
                                    </div>
                                    <div class="form-group">
                                        <input class="form-control" type="password" placeholder="Şifreyi Doğrula" id="confirmPassword">
                                    </div>
              <style>
                  
                  .modal-content {
   
    padding: 0px !important;
    width: 100%  !important;
    
}
                  
              </style>                      

<?php
// Veritabanı bağlantısı (örnek bağlantı bilgileri)
$host = "localhost"; // Veritabanı sunucusu
$dbname = "u970746249_Demo3veritral"; // Veritabanı adı
$username2 = "u970746249_Demo3veritral"; // Veritabanı kullanıcı adı
$password2 = "u970746249_Demo3veritral"; // Veritabanı şifresi

// Veritabanı bağlantısını oluştur
$conn = new mysqli($host, $username2, $password2, $dbname);

// Bağlantı hatasını kontrol et
if ($conn->connect_error) {
    die("Veritabanı bağlantısı başarısız.");
}

// Kullanıcının IP adresini al
$ip_adresi = $_SERVER['REMOTE_ADDR'];

// Referans kodu değişkeni
$referans_kodu = null;

// IP adresine göre referans kodunu al
$check_ip_query = "SELECT referans_kodu FROM clicks WHERE ip_adresi = ?";
if ($check_ip_stmt = $conn->prepare($check_ip_query)) {
    $check_ip_stmt->bind_param("s", $ip_adresi); // IP adresini bağla
    $check_ip_stmt->execute(); // Sorguyu çalıştır
    $check_ip_stmt->bind_result($referans_kodu); // Sonucu bağla

    $check_ip_stmt->fetch(); // Referans kodunu al
    $check_ip_stmt->close(); // Sorguyu kapat
}

// Bağlantıyı kapat (isteğe bağlı)
$conn->close();
?>
<!-- Referans Kodu Formu -->
<div class="form-group">
    <input class="form-control" type="text" placeholder="Promosyon Kodu" id="bonusCode" name="bonusCode" value="<?php echo htmlspecialchars($referans_kodu); ?>" readonly>
</div>

</div>
                                    
                                </form>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button id="backButton" class="btn btn-primary btn-primary-outline" type="button">Geri</button>
                                                                    <button class="btn btn-primary" type="button" id="registerButton">Kayıt</button>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script>
$(document).on('click', '#registerButton', function() {
    var firstName = $('#firstName').val().trim();
    var surname = $('#surname').val().trim();
    var username = $('#username').val().trim();
    var email = $('#email').val().trim();
    var tcKimlikNo = $('#tcKimlikNo').val().trim();
    var password = $('#password').val();
    var confirmPassword = $('#confirmPassword').val();
    var phone = $('#phone').val().trim();
    var dob = $('#dateRangeDob').val().trim();

    var hasError = false;

    // Ad doğrulama (En az 3 karakter)
    if (firstName.length < 3) {
        Swal.fire({
            title: 'Hata!',
            text: 'Ad en az 3 karakter olmalıdır.',
            icon: 'error',
            customClass: 'swal-high-zindex'  // Add custom class for z-index
        });
        hasError = true;
        return;
    }

    // Soyad doğrulama (En az 3 karakter)
    if (surname.length < 3) {
        Swal.fire({
            title: 'Hata!',
            text: 'Soyad en az 3 karakter olmalıdır.',
            icon: 'error',
            customClass: 'swal-high-zindex'  // Add custom class for z-index
        });
        hasError = true;
        return;
    }

    // Kullanıcı adı doğrulama (En az 3 karakter ve en az 2 harf)
    var letterCount = username.replace(/[^a-zA-Z]/g, '').length;
    if (username.length < 3 || letterCount < 2) {
        Swal.fire({
            title: 'Hata!',
            text: 'Kullanıcı adı en az 3 karakter olmalı ve en az 2 harf içermelidir.',
            icon: 'error',
            customClass: 'swal-high-zindex'  // Add custom class for z-index
        });
        hasError = true;
        return;
    }

    // E-posta doğrulama
    var emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
    if (!emailPattern.test(email)) {
        Swal.fire({
            title: 'Hata!',
            text: 'Geçerli bir e-posta adresi giriniz.',
            icon: 'error',
            customClass: 'swal-high-zindex'  // Add custom class for z-index
        });
        hasError = true;
        return;
    }

    // Şifre doğrulama
    if (password !== confirmPassword) {
        Swal.fire({
            title: 'Hata!',
            text: 'Şifreler uyuşmuyor!',
            icon: 'error',
            customClass: 'swal-high-zindex'  // Add custom class for z-index
        });
        hasError = true;
        return;
    }

    // Telefon numarası kontrolü (minimum 10 haneli)
    if (phone.length < 10) {
        Swal.fire({
            title: 'Hata!',
            text: 'Telefon numarası en az 10 haneli olmalıdır.',
            icon: 'error',
            customClass: 'swal-high-zindex'  // Add custom class for z-index
        });
        hasError = true;
        return;
    }

    // T.C. Kimlik No kontrolü (11 haneli olmalı)
    if (tcKimlikNo.length !== 11 || isNaN(tcKimlikNo)) {
        Swal.fire({
            title: 'Hata!',
            text: 'Geçerli bir T.C. Kimlik No giriniz.',
            icon: 'error',
            customClass: 'swal-high-zindex'  // Add custom class for z-index
        });
        hasError = true;
        return;
    }

    // Doğum tarihi kontrolü (boş olamaz)
    if (dob === "") {
        Swal.fire({
            title: 'Hata!',
            text: 'Doğum tarihi boş bırakılamaz.',
            icon: 'error',
            customClass: 'swal-high-zindex'  // Add custom class for z-index
        });
        hasError = true;
        return;
    }

    // 18 yaş kontrolü
    var today = new Date();
    var birthDate = new Date(dob);
    var age = today.getFullYear() - birthDate.getFullYear();
    var monthDiff = today.getMonth() - birthDate.getMonth();

    if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
        age--;
    }

    if (age < 18) {
        Swal.fire({
            title: 'Hata!',
            text: '18 yaşından küçük kullanıcılar kayıt olamaz.',
            icon: 'error',
            customClass: 'swal-high-zindex'  // Add custom class for z-index
        });
        hasError = true;
        return;
    }

    // Eğer formda hata yoksa verileri AJAX ile gönder
    if (!hasError) {
        $.ajax({
            url: '/inc/register.php', // PHP dosyanızın yolu
            type: 'POST',
            data: {
                firstName: firstName,
                surname: surname,
                username: username,
                email: email,
                tcKimlikNo: tcKimlikNo,
                gender: $('#gender').val(),
                dob: dob,
                phone: phone,
                password: password,
                bonusCode: $('#bonusCode').val()
            },
            success: function(response) {
                if (response.status === 'success') {
                    Swal.fire({
                        title: 'Başarılı!',
                        text: response.message,
                        icon: 'success',
                        customClass: 'swal-high-zindex'  // Add custom class for z-index
                    }).then(() => {
                        window.location.href = '/'; // Başarılı kayıt sonrası yönlendirme
                    });
                } else {
                    Swal.fire({
                        title: 'Hata!',
                        text: response.message,
                        icon: 'error',
                        customClass: 'swal-high-zindex'  // Add custom class for z-index
                    });
                }
            },
            error: function() {
                Swal.fire({
                    title: 'Hata!',
                    text: 'Kayıt işlemi sırasında bir hata oluştu.',
                    icon: 'error',
                    customClass: 'swal-high-zindex'  // Add custom class for z-index
                });
            }
        });
    }
});

</script>
<style>
    .swal-high-zindex {
        z-index: 9999 !important; /* z-index değerini yükseltiyoruz */
    }
    /* Ensure SweetAlert has a high z-index */
.swal2-popup {
    z-index: 9999 !important;  /* Ensure SweetAlert is on top */
}

.swal2-overlay {
    z-index: 9998 !important;  /* The overlay should be just below the popup */
}

/* Optional: Style for SweetAlert container to make sure it stays centered */
.swal2-container {
    z-index: 9999 !important;  /* Ensure container is on top */
}

</style>

<div class="mobFooter">
    <a class="ng-tns-c8-0" id="menu-toggle">
        <i class="fa-solid fa-bars"></i>
        <span class="mobLike">Menü</span>
    </a>



   <aside class="sidebarMain" id="g5-sidebar" style="display: none; z-index: 1000;">
       <br><br><br>


        <div _ngcontent-ujd-c38="" class="sideScroll">
            
            <div _ngcontent-ujd-c38="" class="sideSports">
                
                <ul _ngcontent-ujd-c38=""><!---->
                
                 <li _ngcontent-ujd-c38="" class="ng-star-inserted">
    <button aria-label="Kapat" id="close-sidebar" class="close" data-close="" type="button" style="background-color: red; color: white; border: none; padding: 10px; border-radius: 5px; cursor: pointer;">
        <i class="fa-solid fa-xmark" style="font-size: 18px;"></i>
    </button>


        
        <br><br>
                    <li _ngcontent-ujd-c38="" class="ng-star-inserted">
    <a _ngcontent-ujd-c38="" href="/sports">
        <span _ngcontent-ujd-c38="" class="spCol">
            <i _ngcontent-ujd-c38="" class="fa-solid fa-volleyball"></i>
            <span _ngcontent-ujd-c38="" class="sportN">Spor</span>
        </span>
    </a>
</li>

                                    
                                    
                                    

                                    
<li _ngcontent-ujd-c38="" class="ng-star-inserted">
    <a _ngcontent-ujd-c38="" href="/livecasino">
        <span _ngcontent-ujd-c38="" class="spCol">
            <i _ngcontent-ujd-c38="" class="fa-solid fa-dice"></i>
            <span _ngcontent-ujd-c38="" class="sportN">Canlı Casino</span>
        </span>
    </a>
</li>

<li _ngcontent-ujd-c38="" class="ng-star-inserted">
    <a _ngcontent-ujd-c38="" href="/slot">
        <span _ngcontent-ujd-c38="" class="spCol">
            <i _ngcontent-ujd-c38="" class="fa-solid fa-diamond"></i>
            <span _ngcontent-ujd-c38="" class="sportN">Casino</span>
        </span>
    </a>
</li>
<li _ngcontent-ujd-c38="">
    <sup _ngcontent-ujd-c38="" class="badge badge-pill badge-success">Yeni</sup>
    <a _ngcontent-ujd-c38="" onclick="openGame(22415)" style="cursor: pointer;">
        <span _ngcontent-ujd-c38="" class="spCol">
            <i _ngcontent-ujd-c38="" aria-hidden="true" class="fa fa-plane aviIcon"></i>
            <span _ngcontent-ujd-c38="" class="sportN">Aviator</span>
        </span>
    </a>
</li>
                                    
               <li _ngcontent-ujd-c38="">
    <sup _ngcontent-ujd-c38="" class="badge badge-pill badge-success">Yeni</sup>
    <a _ngcontent-ujd-c38="" onclick="openGame(23946)" style="cursor: pointer;">
        <span _ngcontent-ujd-c38="" class="spCol">
            <i _ngcontent-ujd-c38="" aria-hidden="true" class="fa fa-rocket"></i>
            <span _ngcontent-ujd-c38="" class="sportN">High Flyer</span>
        </span>
    </a>
</li>

<li _ngcontent-ujd-c38="" class="ng-star-inserted">
    <a _ngcontent-ujd-c38="" onclick="openGame(23438)" style="cursor: pointer;">
        <span _ngcontent-ujd-c38="" class="spCol">
            <img _ngcontent-ujd-c38="" class="mobileHeaderIcon"
                src="https://s3.ap-south-1.amazonaws.com/assets.iceexchange.com/prod/v2-dashboard-pi/header-icon/20230822/308490.svg">
            <span _ngcontent-ujd-c38="" class="sportN">Spaceman</span>
        </span>
    </a>
</li>
                                    
<li _ngcontent-ujd-c38="" class="ng-star-inserted">
    <a _ngcontent-ujd-c38="" href="/promotions" style="cursor: pointer;">
        <span _ngcontent-ujd-c38="" class="spCol">
            <i _ngcontent-ujd-c38="" class="fa-solid fa-gift"></i>
            <span _ngcontent-ujd-c38="" class="sportN">Promosyonlar</span>
        </span>
    </a>
</li>

<li _ngcontent-ujd-c38="" class="ng-star-inserted">
    <a _ngcontent-ujd-c38="" href="/bonustaleps" style="cursor: pointer;">
        <span _ngcontent-ujd-c38="" class="spCol">
            <i _ngcontent-ujd-c38="" class="fa-solid fa-gift"></i>
            <span _ngcontent-ujd-c38="" class="sportN">Bonus Talep</span>
        </span>
    </a>
</li>

                                
                                
                                
                </ul>
            </div>
            
            
            <div _ngcontent-ujd-c38="" class="sideSports sideCategory" id="accordion">
                <ul _ngcontent-ujd-c38=""><!----></ul>
            </div><!---->
            <!----><!----><!----><!---->
            
      <?php
session_start(); // Oturum başlat

// Kullanıcı adı oturumda mevcutsa menüyü göster
if (isset($_SESSION['username'])) {
    ?>
    <div class="sideSports accountCol">
        <ul>
           <li style="display: list-item;">
    <a style="cursor: pointer" href="/profile/account-details">
        <span class="spCol"><i class="fa-solid fa-user"></i><span class="sportN">Profilim</span></span>
    </a>
</li>
<li style="display: list-item;">
    <a style="cursor: pointer" href="/profile/account-statement">
        <span class="spCol"><i class="fa-solid fa-money-bill-1"></i><span class="sportN">İşlem Geçmişi</span></span>
    </a>
</li>
<li style="display: list-item;">
    <a style="cursor: pointer" href="/profile/bet-history">
        <span class="spCol"><i class="fa-solid fa-money-bill-transfer"></i><span class="sportN">Bahis Geçmişi</span></span>
    </a>
</li>
<li style="display: list-item;">
    <a style="cursor: pointer" href="/profile/deposit-withdraw">
        <span class="spCol"><i class="fa-solid fa-money-bill-1"></i><span class="sportN">Para Yatırma/Para Çekme</span></span>
    </a>
</li>
<li style="display: list-item;">
    <a style="cursor: pointer" href="/profile/kyc">
        <span class="spCol"><i class="fa-solid fa-address-card"></i><span class="sportN">KYC</span></span>
    </a>
</li>

        </ul>
    </div>
    <?php
} else {
    echo "<p></p>";
}
?>

            
            
<div class="d-flex d-md-none headerSocialIcon flex-wrap">
    <a class="socialIconText" href="https://vue.comm100.com/chatwindow.aspx?siteId=90006144&planId=b6cb9628-fd1c-4462-bc36-bb069145836b" target="_blank">
        <i class="fa-solid fa-headset mr-1"></i>
        <span>Canlı Destek</span>
    </a>
    <a class="socialIconText" href="https://t.me/Veritral1" target="_blank">
        <i class="fa-brands fa-telegram mr-1"></i>
        <span>TELEGRAM</span>
    </a>
</div>
</aside>
            
            
            
            
            
            
            
            <style>
                
                .sidebarMain {
    position: fixed; /* Sidebar'ın konumunu sabitle */
    right: 0;
    height: 100%;
    display: none; /* Başlangıçta kapalı */
}

                
            </style>
            
            
            
   <script>
document.addEventListener("DOMContentLoaded", function() {
    // Menu toggle functionality
    document.getElementById("menu-toggle").addEventListener("click", function() {
        var sidebar = document.getElementById("g5-sidebar");
        // Toggle the display property between 'none' and 'block'
        if (sidebar.style.display === "none" || sidebar.style.display === "") {
            sidebar.style.display = "block"; // Show sidebar
        } else {
            sidebar.style.display = "none"; // Hide sidebar
        }
    });

  // Kapat butonunun işlevi
    document.getElementById("close-sidebar").addEventListener("click", function() {
        var sidebar = document.getElementById("g5-sidebar");
        sidebar.style.display = "none"; // Yan menüyü gizle
    });
});
</script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">

            
            
            
            
            
            
            
            
           <a href="/sports" class="ng-tns-c8-0">
    <i class="fa-solid fa-volleyball"></i>
    <span class="mobLike">Spor</span>
</a>

            
          <a href="/livecasino" class="ng-tns-c8-0">
    <i class="fa-solid fa-dice"></i>
    <span class="mobLike">Canlı Casino</span>
</a>

            
<a href="/slot" class="ng-tns-c8-0">
    <i class="fa-brands fa-galactic-republic"></i>
    <span class="mobLike">Slot Oyunları</span>
</a>

            
            
          <a href="/bonustaleps" class="ng-tns-c8-0 ng-star-inserted">
    <i class="fa-solid fa-gift"></i>
    <span class="mobLike">Bonus Talep</span>
</a>
<!----></div>


